﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using IndexMarkSilverlightClient.Views.Help;

namespace IndexMarkSilverlightClient.Views
{
    public partial class Player : Page
    {
        private string server = string.Empty;
        private Frame frame = null;

        public Player(Frame frame, string title, string videoPath, double VideoHeight = 480, double VideoWidth = 640)
        {
            InitializeComponent();

            Uri p = Application.Current.Host.Source;
            this.server = string.Format("{0}://{1}:{2}/VideoHelp/", p.Scheme, p.Host, p.Port);

            this.frame = frame;

            mediaPlayer.Playlist.Items.Add(new ExpressionMediaPlayer.PlaylistItem
            {
                Title = title,
                VideoHeight = VideoHeight,
                VideoWidth = VideoWidth,
                MediaSource = new Uri(string.Format("{0}{1}", server, videoPath))
            });
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.frame.Content = new Menu(frame);
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            mediaPlayer.GoToPlaylistItem(0);
            mediaPlayer.Play();
        }

    }
}
